import java.security.MessageDigest;
import java.util.ArrayList;

/*
 * A child class of 'Member'
 */
public class Nurse extends Member implements java.io.Serializable{
	private ArrayList <Integer> doctorID;
	private MemberData memberData;
	
	//constructor
	public Nurse(String f, String l, MessageDigest p, String u, String a, int id, MemberData m) {
		super(f, l, p, u, a, id);
		doctorID= new <Patient> ArrayList();
		memberData = m;
	}
	
	
	//*****patient handlers********		
	//add id to doctorID ArrayList & the MemberData ArrayList
	public void addNewDoctor(String f, String l, MessageDigest p, String u, String a, int id) { 
		doctorID.add(id); 
		Doctor doctor = new Doctor(f,l,p,u,a,id,memberData);
		memberData.addMember(doctor);
		}
	
	//add an existing Doctor to the Nurse's Doctor list
	public void addExistingDoctor(int id) {
		Member mem = memberData.getMember(id);
		if(mem != null) {	//doctor exists
			if(mem instanceof Doctor) {
				doctorID.add(id);
			}
			else
				System.out.println("addExistingDoctor: The ID entered does not correspond to a Doctor.");
		}
		else
			System.out.println("addExistingDoctor: That member does not exist.");
	}
	
	//remove id from doctorID ArrayList
	public void removeDoctor(int id) { doctorID.remove(doctorID.indexOf(id)); }	//remove takes the index of the object to be removed
	
	//get the size of the doctorID ArrayList
	public int getSize() { return doctorID.size(); }
	
	//get Doctor at index 'index'
	public Doctor getDoctorAt(int index) { 
		int id = doctorID.get(index);
		return getDoctor(id);
	}
	
	//get Doctor based on their ID#
	public Doctor getDoctor(int id) { 
		Member mem;
		if(id < memberData.getSize()) {
			mem = memberData.getMember(id);
			if(mem  instanceof Doctor)		//checks if the Member returned is indeed a Doctor
				return (Doctor)mem;
			else {
				System.out.println("getDoctor: Member returned was not a Doctor.");
				return null;
			}
		}
		else {
			System.out.println("getDoctor: Invalid ID.");
			return null;
		}
	}
}
